<template>
  <div class="resource-publish">
    <SelfAdaption>
      <Form
        :model="searchForm"
        slot="adaption-bar"
        label-position="top"
        class="ivu-form-no-margin-bottom"
        inline
      >
        <Form-item prop="serverClassification" :label="$t('module.serverApi.serverClassification')">
          <Select
            v-model="searchForm.serverClassification"
            
            :placeholder="$t('module.serverApi.serverClassificationSelect')"
          >
            <Option
              v-for="(item, index) in serverClassificationList"
              :key="index"
              :value="item.value"
              :label="item.label"
            ></Option>
          </Select>
        </Form-item>
        <Form-item prop="apiName" :label="$t('module.serverApi.apiName')">
          <Input
            
            :placeholder="$t('module.serverApi.apiNameInput')"
            v-model.trim="searchForm.apiName"
            @on-enter="search"
          />
        </Form-item>
        <Form-item prop="serverProvider" :label="$t('module.serverApi.serverProvider')">
          <Select
            
            :placeholder="$t('module.serverApi.serverProviderSelect')"
            v-model="searchForm.serverProvider"
          >
            <Option
              v-for="(item, index) in serverProviderList"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></Option>
          </Select>
        </Form-item>
      </Form>
    </SelfAdaption>

    <InnerPageTable ref="resourceTable" :config="tableConfig">
      <div slot="table-bar">
        <RPButton
          text="资源配置"
          :optType="'create'"
          @click="add"
        ></RPButton>
      </div>
    </InnerPageTable>
  </div>
</template>

<script>
import locales from "../serverApi/locales";
import { resourcePublishColumns } from './columns'
import resourceEdit from './resourceEdit'

export default {
  name: "resourcePublish",
  mixins: [locales],
  data() {
    return {
      serverClassificationList: [],
      serverProviderList: [],
      searchForm: {
        serverClassification: "",
        apiName: "",
        serverProvider: ""
      }
    }
  },
  computed: {
    tableConfig() {
      return { loadDataFn: this.queryResourcePublishList, columnsFn: resourcePublishColumns.bind(this), autoFirst: false}
    }
  },
  methods: {
    search() {

    },
    add() {
      new this.$pageModal(
        resourceEdit,
        {
          props: {
            tenantCode: this.searchForm.tenantCode
          }
        },
        data => {
          data && this.search();
        }
      )
    },
    queryResourcePublishList() {

    },
    getOperations(menu) {
      let operations = [
        {
          type: "icon",
          icon: "md-create",
          text: this.$t("common.edit"),
          handle: () => {
            this.edit(menu.id, menu);
          }
        },
        {
          type: "icon",
          icon: "ios-settings",
          text: this.$t("module.serviceManage.serviceconfig"),
          handle: () => {
            this.editPermisson(menu);
          }
        },
        {
          type: "icon",
          icon: "ios-trash",
          text: this.$t("common.delete"),
          hidden: menu.enabled == 1,
          handle: () => {
            this.deleted(menu);
          }
        }
      ];
      return operations;
    }
  }
};
</script>

<style scoped>

</style>